package com.test.OrderPattern;

import java.util.ArrayList;
import java.util.List;

/**
 * 命令调用类
 * Broker发出命令，命令由Stock执行
 * <p>
 * Broker可以接受订单和下订单
 *
 * @author muxiaoyu
 * @create 2017/06/19 17:19
 **/
public class Broker {
    private List<Order> orderList = new ArrayList<Order>();

    public void takeOrder(Order order) {
        orderList.add(order);
    }

    public void placeOrders() {
        for (Order order : orderList) {
            order.execute();
        }
        orderList.clear();
    }
}
